#!/usr/bin/python
# coding=utf8
#
# Copyright (C) 2011 XNData contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys, os
sys.path.append (os.getcwd () + '/../../')
import xndata.client
import unittest
import random

class XNClientTestCase (unittest.TestCase):
    
    def testLogin (self):
        # incorrect password
        self.assertRaises (xndata.client.LoginError,
            xndata.client.XNClient, "zhangchitc@gmail.com", "abc")
        # correct password
        client = xndata.client.XNClient ("zhangchitc@gmail.com", "aaaaaaaa");

        self.assertEqual (client.user_id, "242124580")
        self.assertEqual (client.user_name, "张弛")


suite1 = unittest.TestLoader().loadTestsFromTestCase (XNClientTestCase)
allsuite = unittest.TestSuite ([suite1])

unittest.TextTestRunner(verbosity=2).run(allsuite)

